package zhupf.test.designPattern.composite;

import com.alibaba.fastjson.JSON;

/**
 *
 *  组合模式：适合处理树形结构的数据，感觉还是使用递归比较合适
 */
public class Client {
    public static void main(String[] args) {
        University university = new University("清华大学");

        Collage collage = new Collage("软件工程");
        Collage collage1 = new Collage("机械学院");

        collage.add(new Department("计算机与科学"));
        collage.add(new Department("软件开发"));

        collage1.add(new Department("汽车制造"));
        collage1.add(new Department("机电一体化"));
        university.add(collage);
        university.add(collage1);

        university.print();
        System.out.println(university);

        String s = JSON.toJSONString(university);
        System.out.println(s);

    }
}
